package com.ruoyi.tcm.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.tcm.mapper.TcmKnowledgeMapper;
import com.ruoyi.tcm.domain.TcmKnowledge;
import com.ruoyi.tcm.service.ITcmKnowledgeService;

/**
 * 知识Service业务层处理
 *
 * @author cong
 * @date 2025-02-07
 */
@Service
@Slf4j
public class TcmKnowledgeServiceImpl implements ITcmKnowledgeService {

    @Autowired
    private TcmKnowledgeMapper tcmKnowledgeMapper;

    /**
     * 查询知识
     *
     * @param id 知识主键
     * @return 知识
     */
    @Override
    public TcmKnowledge selectTcmKnowledgeById(Long id) {
        return tcmKnowledgeMapper.selectTcmKnowledgeById(id);
    }

    /**
     * 查询知识列表
     *
     * @param tcmKnowledge 知识
     * @return 知识
     */
    @Override
    public List<TcmKnowledge> selectTcmKnowledgeList(TcmKnowledge tcmKnowledge) {
        log.info("info: {}", 1);
        return tcmKnowledgeMapper.selectTcmKnowledgeList(tcmKnowledge);
    }

    /**
     * 新增知识
     *
     * @param tcmKnowledge 知识
     * @return 结果
     */
    @Override
    public int insertTcmKnowledge(TcmKnowledge tcmKnowledge) {
        tcmKnowledge.setCreateTime(DateUtils.getNowDate());
        return tcmKnowledgeMapper.insertTcmKnowledge(tcmKnowledge);
    }

    /**
     * 修改知识
     *
     * @param tcmKnowledge 知识
     * @return 结果
     */
    @Override
    public int updateTcmKnowledge(TcmKnowledge tcmKnowledge) {
        tcmKnowledge.setUpdateTime(DateUtils.getNowDate());
        return tcmKnowledgeMapper.updateTcmKnowledge(tcmKnowledge);
    }

    /**
     * 批量删除知识
     *
     * @param ids 需要删除的知识主键
     * @return 结果
     */
    @Override
    public int deleteTcmKnowledgeByIds(Long[] ids) {
        return tcmKnowledgeMapper.deleteTcmKnowledgeByIds(ids);
    }

    /**
     * 删除知识信息
     *
     * @param id 知识主键
     * @return 结果
     */
    @Override
    public int deleteTcmKnowledgeById(Long id) {
        return tcmKnowledgeMapper.deleteTcmKnowledgeById(id);
    }
}
